<meta meta="客服信息配置" args="data"/>
<style>

</style>
<form class="form-horizontal" id="form" s="form,datac,nda,valid" s-data="data" style="width: 600px;">
    <div class="form-group">
        <label class="col-sm-3 control-label">客服微信号</label>
        <div class="col-sm-9">
            <input autocomplete="off" type="text" class="form-control" name="weixin" placeholder="客服微信号"
                   s-valid-error="require()"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">客服微信号二维码</label>
        <div class="col-sm-9">
            <div s="tpl"  id="icon" s-click="selectIcon()">
                <img src="{%=this.weixinQrcodeUrl || 'images/upload-bg.jpg'%}" class="qrcode-pic" style="max-width: 200px; max-height: 200px;" />
                <input autocomplete="off" type="hidden" name="weixinQrcode" value="{%=this.weixinQrcode%}" />
            </div>
            <a href="javascript:;" s-click="removeIcon()">删除</a>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">客服微信描述</label>
        <div class="col-sm-9">
            <input autocomplete="off" type="text" class="form-control" name="weixinDesc" placeholder="客服微信描述"
                   s-valid-error="require()"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">客服电话</label>
        <div class="col-sm-9">
            <input autocomplete="off" type="text" class="form-control" name="servicePhone" placeholder="客服电话"
                   s-valid-error="require()"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">服务时间</label>
        <div class="col-sm-9">
            <input autocomplete="off" type="text" class="form-control" name="serviceTime" placeholder="服务时间"
                   s-valid-error="require()"/>
        </div>
    </div>
</form>
<script type="text/javascript">
    S.getContent = function () {
        var deferred = $.Deferred();
        $form.validate().done(function() {
            deferred.resolve(Smart.serializeToObject($form.node))
        })
        return deferred;
    }

    function removeIcon() {
        $icon.data({
            weixinQrcode: "",
            weixinQrcodeUrl: "",
        })
    }
    function selectIcon() {
        S.popupOpen("/oss/objects-selector.html", {prefix: 'operation'}).done(function(datas) {
            if(datas) {
                var icon = datas[0];
                $icon.data({
                    weixinQrcode: icon.key,
                    weixinQrcodeUrl: icon.url,
                })
            }
        })
    }
</script>